using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace ArchSoft
{
    public partial class PrInfFrmReport : Form
    {
        //XML Data file path
        string _path;
        //Global
        DataSet1 ds = new DataSet1();
        DataSet1.ProjectInformationRow row;
        CrystalReportProjectInformation rpt = new CrystalReportProjectInformation();

        public PrInfFrmReport()
        {
            InitializeComponent();
        }
        public string FilePath
        {
            get { return _path; }
            set { _path = value; }
        }
        public void LoadData()
        {
            try
            {
                if (File.Exists(_path))
                {
                    DataSet ds2 = new DataSet();
                    ds2.ReadXml(_path);
                    DataTable dt = new DataTable();
                    dt = ds2.Tables[0].Copy();

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        row = ds.ProjectInformation.NewProjectInformationRow();

                        row["ProjectName"] = dt.Rows[i]["ProjectName"].ToString();
                        row["StartDate"] = dt.Rows[i]["StartDate"].ToString();
                        row["EndDate"] = dt.Rows[i]["EndDate"].ToString();
                        row["ServiceRequested"] = dt.Rows[i]["ServiceRequested"].ToString();
                        row["Owner"] = dt.Rows[i]["Owner"].ToString();
                        row["Category"] = dt.Rows[i]["Category"].ToString();
                       // row["Logo"] = dt.Rows[i]["Logo"].ToString();
                        row["Value"] = dt.Rows[i]["Value"].ToString();
                        row["Tel"] = dt.Rows[i]["Tel"].ToString();
                        row["Fax"] = dt.Rows[i]["Fax"].ToString();
                        row["Location"] = dt.Rows[i]["Location"].ToString();
                        row["Email"] = dt.Rows[i]["Email"].ToString();
                        row["Website"] = dt.Rows[i]["Website"].ToString();
                        row["ProjectDescription"] = dt.Rows[i]["ProjectDescription"].ToString();
                        row["ConsultantsName"] = dt.Rows[i]["ConsultantsName"].ToString();
                        row["ConsultantsAddress"] = dt.Rows[i]["ConsultantsAddress"].ToString();
                        row["ConsultantsTelNo"] = dt.Rows[i]["ConsultantsTelNo"].ToString();
                        row["ConsultantsFaxNo"] = dt.Rows[i]["ConsultantsFaxNo"].ToString();
                        row["ConsultantsWebsite"] = dt.Rows[i]["ConsultantsWebsite"].ToString();

                        row["ContactName"] = dt.Rows[i]["ContactName"].ToString();
                        row["ContactPosition"] = dt.Rows[i]["ContactPosition"].ToString();
                        row["ContactEmail"] = dt.Rows[i]["ContactEmail"].ToString();
                        row["ContactOfficeNo"] = dt.Rows[i]["ContactOfficeNo"].ToString();
                        row["ContactCellNo"] = dt.Rows[i]["ContactCellNo"].ToString();

                        row["Comment"] = dt.Rows[i]["Commnent"].ToString();
                        row["CommentC"] = dt.Rows[i]["CommnentC"].ToString();

                        ds.ProjectInformation.AddProjectInformationRow(row);
                    }
                }
            }
            catch (Exception ex)
            {

            }
        }

        private void PrInfFrmReport_Load(object sender, EventArgs e)
        {
            rpt.SetDataSource(ds);
            crystalReportViewer1.ReportSource = rpt;
        }
    }
}